package com.blueocean_health.care.management.domain.dto;

import java.util.HashMap;
import java.util.Map;

import com.blueocean_health.care.management.domain.ordervo.OrderRefundVo;
import com.blueocean_health.care.management.em.PayTypeEnum;
import com.blueocean_health.care.management.util.AES;

import lombok.Data;

/**
 * 请求拉卡拉退款实体
 * 
 * @todo
 * @author 张亚林
 * @date 2018年8月16日 下午4:20:19
 */
@Data
public class OrderRefundLklReqDto {

	private String appName;
	private String appKey;
	private long timestamp;
	private String sign;
	private Object body;
	private String midUuid;

	public OrderRefundLklReqDto(String appname, String appkey, String appSecret, OrderRefundVo orderVo) {
		this.appName = appname;
		this.appKey = appkey;
		this.timestamp = System.currentTimeMillis() / 1000;
		String str = String.format("appKey=%s&appSecret=%s&applyName=%s&timestamp=%s", appkey, appSecret, appname,
				this.timestamp);
		this.sign = AES.GetMD5(str).toUpperCase();
		this.midUuid=orderVo.getMidUuid();
		Map<String, String> map = new HashMap<>();
		map.put("reqLogNo", orderVo.getReqLogNo());
		map.put("ornReqLogNo", orderVo.getPayRecordLogNo());
		map.put("payChlTyp", PayTypeEnum.ValOfKey(orderVo.getTransType()));// 支付渠道类型 默认：WECHAT(微信) ALIPAY(支付宝)
		map.put("txnAmt", String.valueOf((int)(Double.parseDouble(orderVo.getAmount()) * 100)));
		map.put("sub_appid", orderVo.getSubAppid());
		this.body = map;
	}

}
